package com.njbdqn.qiy_shop.shopdao;

import java.util.List;

import org.njbdqn.commons.database.PageHelper;
import org.njbdqn.commons.database.SqlTemplate;

import com.njbdqn.qiy_shop.shopentity.Commodity;
import com.njbdqn.qiy_shop.shopvo.MiaoShaVO;



public class MiaoShaDAO {
	private SqlTemplate tem;
	private PageHelper ph;
	
	public MiaoShaDAO() {
		this.tem = new SqlTemplate();
		this.ph = new PageHelper();
	}
	
	public List<MiaoShaVO> resultToList(){
		String sql ="select cm.*,s.shoppicname from commodity cm inner join "
				+ "(select * from shoppic group by commodityid) s on cm.commodityid=s.commodityid";
		return tem.resultToArray(sql, new Object[]{}, MiaoShaVO.class);
	}
	
	public MiaoShaVO findById(int commodityid){
		String sql = "select * from commodity where commodityid=? ";
		return  (MiaoShaVO)tem.resultToArray(sql, new Object[]{commodityid},Commodity.class).get(0);
	}
	
	
}
